<?php
if(!isset($_GET['access_token']))
{
	$oAuth_req = dirname($_SERVER['REQUEST_URI']) . "/oAuth_req.php";
	echo "<code>An access_token is necessary for api calling";
	echo "<br/>Open <a href='$oAuth_req'>OAuth_req.php</a> to begin</code>";
	die;
}

include_once('lib.L2P.php');
// Instantiate new l2p object
$l2p = new L2P($_GET['access_token']);

// =====================VIEW ALL COURSE INFO => GET
$method="viewAllCourseInfo";

$urlParam = array();
$urlParam['accesstoken'] = $l2p->token;
$urlParam['cid'] = "14ws-42879";

$result = $l2p->GET($method, $urlParam);
echo '<pre>';
	print_r(json_decode($result,true));
echo '</pre>';

// =====================ADD NEW DISCUSSION THREAD => POST
$method="addDiscussionThread";

$postMethodUrlParam = array();
$postMethodUrlParam['accesstoken'] = $l2p->token;
$postMethodUrlParam['cid'] = "14ws-42879";

$postMethodBodyParam = array();
$postMethodBodyParam["body"] = "From demo purpose";
$postMethodBodyParam["subject"] = "This is a sample discussion thread.";

$result = $l2p->POST($method, $postMethodUrlParam, $postMethodBodyParam);
echo '<pre>';
	print_r(json_decode($result));
echo '</pre>';
?>